#ifndef __ATOM__
#define __ATOM__

#include "OSHeaders.h"

#define MAKEATOM(buf) (buf[3] << 24 | buf[2] << 16 | buf[1] << 8  | buf[0])

using namespace std;

struct atom_header_t
{
	UInt32	size;
	UInt32	type;
};

struct atom_mvhd_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flag[3];
	UInt32	create_time;
	UInt32	modify_time;
	UInt32	time_scale;
	UInt32	duration;
	UInt32	preferred_rate;
	UInt16	preferred_vol;
	UChar	Reserved[10];
	UChar	matrix[36];
	UInt32	preview_time;
	UInt32	previre_duration;
	UInt32	poster_time;
	UInt32	selection_time;
	UInt32	selection_duration;
	UInt32	current_time;
	UInt32	next_trackid;
};

struct atom_tkhd_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flag[3];
	UInt32	create_time;
	UInt32	modify_time;
	UInt32	track_id;
	UInt32	reserved1;
	UInt32	duration;
	UInt32	reserved2[2];
	UInt16	layer;
	UInt16	alternate_group;
	UInt16	volume;
	UInt16	reserved3;
	UChar	matrix[36];
	UInt32	track_width;
	UInt32	track_height;
};

struct atom_mdhd_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flag[3];
	UInt32	create_time;
	UInt32	modify_time;
	UInt32	time_scale;
	UInt32	duration;
	UInt16	lanauage;
	UInt16	quality;
};

struct atom_hdlr_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flag[3];
	UInt32	component_type;
	UInt32	component_subtype;
	UInt32	component_manufacturer;
	UInt32	component_flags;
	UInt32	component_mask;
};

struct atom_stts_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flags[3];
	UInt32	number;
};

struct atom_stss_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flags[3];
	UInt32	number;
};

struct atom_stsc_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flags[3];
	UInt32	number;
};

struct atom_stsz_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flags[3];
	UInt32	size;
	UInt32	number;
};

struct atom_stco_t
{
	atom_header_t	atomheader;
	UChar	version;
	UChar	flags[3];
	UInt32	number;
};

#endif
